import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { LayerManager } from "../../manager/LayerManager";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { DailyType } from "../../rules/DailyType";
import { DailyRule } from "../../rules/DailyRule";
import { MarketOpenIndexConst } from "../market/MarketOpenIndexConst";
import { PulseSharedObject } from "../player/PulseSharedObject";
import { TodayNoTipsConst } from "../../../component/gconst/TodayNoTipsConst";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
import { GButton } from "../../../../com/mui/controls/GButton";
import { GCheckBox } from "../../../../com/mui/controls/GCheckBox";
import { SpaSoapFirstIdx } from "../../../../MarketOpenIndexConst/SpaSoapFirstIdx";
import { SpaSoapSecondIdx } from "../../../../MarketOpenIndexConst/SpaSoapSecondIdx";
//class SpaSoapTipsWin
    
    export  class SpaSoapTipsWin extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(328, 200);
            this.layer = LayerManager.windowLayer;
            this.titleHeight = 25;
            this.title = Language.getString(69900);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(16, 36, 296, 153, this);
            this._text1 = ObjCreate.createTextField(Language.getString(60705), 27, 45, 100, 20, this);
            this._text1.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._text2 = ObjCreate.createGTextField("", this._text1.x + this._text1.width, this._text1.y, 280, 20, this);
            this._text2.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._text2.htmlText = HTMLUtil.addColor(Language.getString(60706), GlobalStyle.color5);
            this._text2.toolTipData = HTMLUtil.addColor(Language.getString(60704), "#FFFFFF");
            this._text3 = ObjCreate.createTextField(Language.getString(60707), this._text2.x + this._text2.width, this._text1.y, 100, 20, this);
            this._text = ObjCreate.createTextField("", 27, this._text1.y + this._text1.height + 5, 280, 80, this, new GTextFormat(FontUtil.songtiName, 12, GlobalStyle.color1Uint, null, null, null, null, null, null, null, null, null, 5));
            this._text.htmlText = Language.getString(60708);
            this._text.wordWrap = true;
            this._text.multiline = true;
            this._text.addEventListener(flash.events.TextEvent.LINK, this.onTextFieldLinkClick);
            this._okBtn = ObjCreate.createGButton(Language.getString(69901), 84, 135, 60, 26, this);
            this._cancelBtn = ObjCreate.createGButton(Language.getString(69902), 174, this._okBtn.y, 60, 26, this);
            this._okBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            this._cancelBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            this._checkBox = ObjCreate.createCheckBox(Language.getString(60709), 27, 165, 200, 20, this);
            return;
        }

        /* internal  */onTextFieldLinkClick(arg1: Object /* flash.events.TextEvent */): void
        {
            var loc1=arg1.text;
            switch (loc1) 
            {
                case "守护灵源":
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.DailyTabOpenByType, new DailyType(DailyRule.TypeCopy, DailyRule.Copy112)));
                    break;
                }
                case "智慧答题":
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.DailyTabOpenByType, new DailyType(DailyRule.TypeEveryDay, DailyRule.Question)));
                    break;
                }
                case "市场快速购买":
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.MarketOpenSpecialTag, {"oneId": SpaSoapFirstIdx, "twoIndex": SpaSoapSecondIdx}));
                    break;
                }
            }
            return;
        }

        /* internal  */onButtonClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (arg1.target == this._okBtn) 
            {
                PulseSharedObject.save(TodayNoTipsConst.SpaLackSoapTodayNoTips, this._checkBox.selected);
            }
            this.hide();
            return;
        }

        /* internal */ /* var */_text1: Object /* flash.text.TextField */;

        /* internal */ /* var */_text2: GTextFiled;

        /* internal */ /* var */_text3: Object /* flash.text.TextField */;

        /* internal */ /* var */_text: Object /* flash.text.TextField */;

        /* internal */ /* var */_okBtn: GButton;

        /* internal */ /* var */_cancelBtn: GButton;

        /* internal */ /* var */_checkBox: GCheckBox;
    }
